package com.gym.controller;

import com.wf.captcha.SpecCaptcha;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
public class CodeController {
    @RequestMapping("/hello")
    public void hello(HttpServletResponse response) throws IOException {

        // png类型
        SpecCaptcha captcha = new SpecCaptcha(130, 48);
        String text = captcha.text();// 获取验证码的字符
        char[] chars = captcha.textChar();// 获取验证码的字符数组

        System.out.println("验证码："+text);
        System.out.println(chars);
        // 输出验证码
        captcha.out(response.getOutputStream());
    }
}
